﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Elements {
  public class StaticFrame:StaticScreenPiece, IUIElement<StaticFrame> {
    public StaticFrame ( UIDocument doc , string name ) : base( doc , name ) {
    }
    public StaticFrame ( UIDocument doc ) : this( doc , "StaticFrame" ) {
    }

    #region IUIElement<StaticFrame> Members

    public void Validate ( StaticFrame val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        StaticFrame el = new StaticFrame( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }

    public void Copy ( StaticFrame val ) {
      base.Copy( val );

      if( !string.IsNullOrEmpty( val.FrameTemplate ) )
        this.FrameTemplate = val.FrameTemplate;
    }

    #endregion

    public string FrameTemplate {
      get {
        return this.GetElement( "FrameTemplate" ).InnerText;
      }
      set {
        this.Validate( "FrameTemplate" , value );
      }
    }
  }
}
